/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package futbol5;

import java.awt.Color;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JProgressBar;

/**
 *
 * @author Ivan
 */
public class TiempoProgressBar extends JProgressBar implements PropertyChangeListener {

    private Contador task;

    public TiempoProgressBar() {
        super(0, 60);
        setValue(60);
        setStringPainted(true);

        task = new Contador(60);
        task.addPropertyChangeListener(this);
        task.execute();

    }

    public void propertyChange(PropertyChangeEvent evt) {
        if ("progress" == evt.getPropertyName()) {
            int nuevoValor = (Integer) evt.getNewValue();
            setValue(nuevoValor);
            setString(nuevoValor + "m");

            if(nuevoValor == 58){
                setBackground(Color.red);
                repaint();
            }
        }
    }
}
